<!DOCTYPE html>
<html class="Content">
<head>
    <title>xUnit.js: Asynchronous Tests</title>
    <link type="text/css" rel="Stylesheet" href="../../Style/documentation.css" />
</head>
<body>
    <h1>Asynchronous Tests</h1>
    <p>
        Some javascript hosts provide asynchronous execution of certain APIs and sub-structures, such as file I/O operations, and http:// requests. 
        It can be useful to write integration tests against these operations, targeted specifically at each host.
    </p>
    <p>
        If a fact is marked asynchronous (<em>Fact</em><strong>.Asynchronous=true;</strong>), the fact method will be passed a callback delegate, which must be invoked 
        as the Assert phase of the test, e.g.
        <span class="Code">
function SetsPageTitle(callback){
    // Arrange
    var expected="My Page Title";
    var target="http://my.test.site/";

    // Act
    page.load(target, function(pageObject){
        callback(function(){
            var actual=pageObject.title;
        
            // Assert
            Assert.Equal(expected, actual);
        });
    })
}
        </span>
    </p>
</body>
</html>